package com.gzz.orchid.context.infrastructure.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;

/**
 * @author higmd
 */
public enum SpuStatus implements IBaseEnum {
    CREATED(0, "创建")
    , SUBMITTED(1, "提交")
    , WAITING(2, "待审核")
    , ON_SALE(3, "上架")
    , OFF_SALE(4, "下架");

    private final int code;
    private final String text;

    SpuStatus(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static SpuStatus parse(int val) {
        for (SpuStatus action : SpuStatus.values()) {
            if (action.code == val) {
                return action;
            }
        }
        throw new IllegalArgumentException("Invalid Action value: " + val);
    }

    public static SpuStatus of(String name) {
        return Enum.valueOf(SpuStatus.class, name);
    }

    @Override
    public Integer getValue() {
        return this.code;
    }

    @Override
    public String getLabel() {
        return this.text;
    }

}
